package cn.magictodo.weblog.web.init;

import com.github.jaemon.dinger.DingerSender;
import com.github.jaemon.dinger.core.entity.DingerRequest;
import com.github.jaemon.dinger.core.entity.enums.MessageSubType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @author liu
 * @since 2024-01-09 18:42
 */
@Component
@Slf4j
public class AppInit implements InitializingBean {
    @Autowired
    private DingerSender dingerSender;
    @Override
    public void afterPropertiesSet() throws Exception {
        // 发送text类型消息
        dingerSender.send(
                MessageSubType.MARKDOWN,
                DingerRequest.request("weblog启动成功:"+ LocalDateTime.now(), "应用启动通知")
        );
        log.info("weblog启动成功:"+ LocalDateTime.now());
    }
}
